#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Author: Faker.Deng
Exercise after Chapter 1 Problem 8
"""


# Problem 8
def file_view():
    """
    Input a file and view lines
    :return: None
    """
    file_name = input("Please input the text file name: ")
    file = open(file_name, 'r')
    file_data = list(file)
    line_num = len(file_data)
    while True:
        line = int(input("Total lines number is %d, please input which line you want to view(\"0:\"exit): " % line_num))
        if line == 0:
            print("Exit")
            break
        print(file_data[line - 1].strip())
    return


if __name__ == "__main__":
    file_view()
